<?php if (count($languages) > 1) { ?>
    <div style="display: inline-block">
        <a id="open_languages" data-role="button"><?php echo $text_language; ?></a>

        <?php
        $lang_html = '';
        foreach ($languages as $language) {
            $lang_html .= '<form action=\'' . $action . '\' method=\'post\' enctype=\'multipart/form-data\'>';
            $lang_html .= '<input type=\'image\' src=\'image/flags/' . $language['image'] . '\' alt=\'' . $language['name'] . '\' value=\'' . $language['name'] . '\' />';
            $lang_html .= '<input type=\'hidden\' name=\'language_code\' value=\'' . $language['code'] . '\' /><input type=\'hidden\' name=\'redirect\' value=\'' . $redirect . '\' />';
            $lang_html .= '</form>';
        }
        ?>
        <script type="text/javascript">
            $(document).delegate('#open_languages', 'click', function() {
                $(this).simpledialog({
                    'mode': 'blank',
                    'prompt': false,
                    'forceInput': false,
                    'useModal':true,
                    'fullHTML':
                        "<?php echo $lang_html ?><a rel='close' data-role='button' href='#' id='simpleclose'>Close</a>"
                })
            });
        </script>
    </div>
<?php } ?>
